<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button id="app">点击</button>
</body>

</html>
<script>
    let app = document.getElementById("app")
    
    // 利用了 计时器 和 闭包的功能完善的
    function fn() {console.log("====")}
    let fangdou = function (fn) {
        // fn 是业务函数
        let timer = null
        return function(){
             clearTimeout(timer)
             timer = setTimeout(function(){
                fn()
            },2000)
            
        }
    }
    let newfn = fangdou(fn) // 新的业务函数
    app.onclick = function(){
        //
        newfn()
    }
</script>